//
//  GXLoginViewController.m
//  IPhoneX适配
//
//  Created by 训网高 on 2018/5/2.
//  Copyright © 2018年 训网高. All rights reserved.
//

#import "GXLoginViewController.h"

@interface GXLoginViewController ()

@end

@implementation GXLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"登录";
    [self hideTabbar];
    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    loginButton.frame = CGRectMake(20, Height_NavBar+20, SCREEN_WIDTH - 40, 40);
    loginButton.backgroundColor = [UIColor cyanColor];
    [loginButton setTitle:@"登录" forState:UIControlStateNormal];
    [loginButton addTarget:self action:@selector(loginButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginButton];
    
    
//    [self setLeftBarButtonItem];
}

#pragma mark ---- 登录按钮点击事件
- (void)loginButtonAction:(UIButton *)sender {
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"login_name"] = @"11111111124";
    params[@"login_pwd"] = @"123456";
    params[@"platform"] = @"ios";
    
    [self loginWithPamars:params WithUrl:[NSString stringWithFormat:@"%@login/doLogin",GX_BASE_URL]];
}


#pragma mark ---- 网络请求
- (void)loginWithPamars:(NSDictionary *)pamars WithUrl:(NSString *)urlStr{
    [[NetworkRequestModel shareNetworkRequestModel] loginWithParams:pamars WithUrlString:urlStr resultDic:^(GXResponse *result) {
        DLog(@"%@",result.result);
        NSString *code = [NSString stringWithFormat:@"%@",result.result[@"e"][@"code"]];
        if ([code isEqualToString:@"0"]) {
            //请求成功，保存数据
            
        } else {
            NSString *desc = [NSString stringWithFormat:@"%@",result.result[@"e"][@"desc"]];
            [self showHint:desc];
        }
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
